    <script src="/static/jquery.tablesorter.min.js" type="text/javascript"></script>
    <script type="text/javascript">
      function updateTable()
      {
        $("table.assettable tr:even").addClass("altrow");
        $("table.assettable tr:odd").removeClass("altrow");
        $("table.assettable thead tr").removeClass("altrow");
      }

      function init ()
      {
        $("#assettable").tablesorter();
        $("#assettable").bind("sortEnd", updateTable);
      }

      function handleDirectorySelect()
      {
        var dir = $(".directory_select option:selected").val();
        window.location = "manage?dir=" + dir
      }

      window.onload = init;
    </script>
    <h2>{{assets.count}} Assets in {{current_path}}</h2>
    Directory: 
     <select name="directory" class="directory_select" onchange="handleDirectorySelect();">
	{% for d in directories %}
	<option value="{{d.1}}" {%ifequal current_path d.0 %}SELECTED{% else %}{% endifequal %}>
	  {{d.0}}
	</option>
      {% endfor %}
    </select>    
    <center>
      <table id="assettable" cellspacing="0" cellpadding="0" border="0" class="assettable">
	<thead>
	  <tr>
	    <th>Name</th>
	    <th>Size</th>
	    <th>Mime Type</th>
	    <th>Created by</th>
	    <th>Created</th>
	    <th></th>
	  </tr>
	</thead>
	<tbody>
	  {% for a in assets %}
	  <tr {% if forloop.counter|divisibleby:"2" %}class="altrow"{% else %}class=""{% endif %}>
	    <td><a href="{{base_url}}asset/{{a.asset_key.key}}">{{a.asset_key.filename}}</a></td>
	    <td>{{a.asset_key.size|fileSize:"0"}}</td>
	    <td>{{a.asset_key.content_type}}</td>
	    <td>{{a.created_by}}</td>
	    <td>{{a.asset_key.creation|date:"r"}}</td>
	    <td>
	      <center>
		<a href="{{base_url}}delete?id={{a.asset_key.key}}">
		  <img alt="Delete Asset" src="{{base_url}}static/delete.png">
		</a>
		<a href="{{base_url}}asset/{{a.asset_key.key}}">
		  <img alt="View Asset" src="{{base_url}}static/page_go.png">
		</a>
	      </center>
	    </td>
	  </tr>
	  {% endfor %}
	</tbody>
      </table>
    </center>
    <h2>Upload Asset</h2>
    <center>
      <form action="{{upload_url}}" method="post" enctype="multipart/form-data">
	<input type="hidden" name="directory_id" value="{{current_directory_id}}" />
	<table class="" cellspacing="5" cellpadding="5" border="0">
	  <tr>
	    <td><input type="file" name="asset_file" /></td>
	  </tr>
	  <tr>
	    <td>
	      <p align="right">
		<input type="submit" value="Upload"/>
	      </p>
	    </td>
	  </tr>
	</table>
      </form>
    </center>
    <h2>Create Directory</h2>
    <center>
      <form action="{{base_url}}createdirectory" method="get">
	<input type="hidden" name="directory_id" value="{{current_directory_id}}" />
	<table cellspacing="5" cellpadding="5" border="0">
	  <tr>
	    <td>
	      Name: <input type="text" name="directory_name">
	    </td>
	    <td>
	      <input type="submit" value="Create" />
	    </td>
	  </tr>
	</table>
      </form>
    </center>
  </center>

